 #include<stdio.h>
#include<string.h>

const int size = 150;

typedef struct{
    char id[25];
    char name[25];
    float ave;
    int availabe;//ava为1时学生存在
} Student;


void Deflault(Student *stu, int size);//初始化

void C1(Student *stu, int size);
void C2(Student *stu, int size);
void C3(Student *stu, int size);
void C4(Student *stu, int size);

void get(Student *stu);//辅助函数

int main(){
    int n;
    scanf("%d", &n);
    Student stu[size];
    Deflault(stu, size);
    for(int i = 0; i < n; i++){
        int t;
        scanf("%d", &t);
        switch(t){
            case 1:C1(stu, size);
                break;
            case 2:C2(stu, size);
                break;
            case 3:C3(stu, size);
                break;
            case 4:C4(stu, size);
                break;
        }
    }
    return 0;
}

void Deflault(Student *stu, int size){
    for(int i = 0; i < size; i++){
        stu[i].availabe = 0;
    }
}

void C1(Student *stu, int size){
    Student t;//暂存区
    get(&t);
    for(int i = 0; i < size; i++){
        if(!strcmp(t.id, stu[i].id) && (stu[i].availabe == 1)){
            printf("Students already exist\n");
            return;
        }
    }
    for(int i = 0; i < size; i++){
        if(stu[i].availabe == 1) continue;

        stu[i].ave = t.ave;
        strcpy(stu[i].name, t.name);
        strcpy(stu[i].id, t.id);
        stu[i].availabe = 1;
        printf("Add success\n");
        return;
    }
}

void get(Student *stu){
    getchar();
    scanf("%s", stu->id);
    scanf("%s", stu->name);
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    stu->ave = (float)(a + b + c) / 3;
}


void C2(Student *stu, int size){
    char t[25];
    getchar();
    scanf("%s", t);

    for(int i = 0; i < size; i++){
        if(stu[i].availabe == 1 && !strcmp(t, stu[i].id)){
            stu[i].availabe = 0;
            printf("Delete success\n");
            return;
        }
    }
    printf("Students do not exist\n");
    return;
}

void C3(Student *stu, int size){
    getchar();
    char ch[25];
    int a, b, c;
    scanf("%s", ch);
    scanf("%d %d %d", &a, &b, &c);
    float t = (float)(a + b + c) / 3;

    for(int i = 0; i < size; i++){
        if(stu[i].availabe == 1 && !strcmp(ch, stu[i].id)){
            stu[i].ave = t;
            printf("Update success\n");
            return;
        }
    }

    printf("Students do not exist\n");
    return;
}


void C4(Student *stu, int size){
    char t[25];
    getchar();
    scanf("%s", t);

    for(int i = 0; i < size; i++){
        if(stu[i].availabe == 1 && !strcmp(t, stu[i].id)){
            printf("Student ID:%s\n", stu[i].id);
            printf("Name:%s\n", stu[i].name);
            printf("Average Score:%.1f\n", stu[i].ave);
            return;
        }
    }
    printf("Students do not exist\n");
    return;
}
